package day2.scaladay01

object ArrayDemo {
  def main(args: Array[String]): Unit = {
    val immutableArray = new Array[Int](8)
    val immutableArray2 = Array(1, 2, 3)
    val immutableArray3 = Array("huangbo", "liuyifei", "wangbaoqiang")

    println(immutableArray)
    println(immutableArray2)
    println(immutableArray3)

    println(immutableArray.toBuffer)
    println(immutableArray2.toBuffer)
    println(immutableArray3.toBuffer)

    for (i <- immutableArray) print(i + "\t")
    println()
    for (i <- immutableArray2) print(i + "\t")
    println()

    println(immutableArray(2))
    println(immutableArray(2) = 30)

    immutableArray(2) = 30435

    val array = Array(1, 2, 3, 4, 5, 6)

    for(i <- array) print(i + "\t")
    println()

    for(i <- array.reverse) print(i + "\t")
    println()

    for(i <- (0 until array.length).reverse) print("("+i+":"+array(i)+")\t")
    println()

  }
}
